import { WeaTools } from 'ecCom';
export const newUrl = '/api/cube/board/'
export const CallAPI = (url, method, params) => {
    return new Promise((resolve, reject) => {
        WeaTools.callApi(url, method, params).then(({ noRight, ...data }) => {
            if (noRight) {
                resolve({ noRight, ...data } as any)
            } else {
                resolve(data as any)
            }
        })
    })
}


export const getBoardDatas = (params) => {
    return CallAPI(`${newUrl}getBoardDatas`, "get", params);
}

export const getBoardQuickSearch = (params) => {
    return CallAPI(`${newUrl}getBoardQuickSearch`, "get", params);
}

export const getIdByCondition = (params) => {
    return CallAPI(`${newUrl}getIdByCondition`, "get", params);
}

export const saveGroupOrder = (params) => {
    return CallAPI(`${newUrl}saveGroupOrder`, "post", params);
}

export const addGroup = (params) => {
    return CallAPI(`${newUrl}addGroup`, "post", params);
}

export const deleteGroup = (params) => {
    return CallAPI(`${newUrl}deleteGroup`, "post", params);
}

export const saveItemOrder = (params) => {
    return CallAPI(`${newUrl}saveItemOrder`, "post", params);
}

export const getConditionInfo = (params) => {
    return CallAPI(`/api/cube/search/condition`, "get", params);
}

export const getAppInfoByID = (params) => {
    return CallAPI(`${newUrl}mode/app/getAppInfoByID`, "GET", params);
}

export const checkRight = (params) => {
    return CallAPI(`${newUrl}checkRight`, "get", params);
}

export const updateGroupName = (params) => {
    return CallAPI(`${newUrl}updateGroupName`, "post", params);
}

export const getChengedItems = (params) => {
    return CallAPI(`${newUrl}getChengedItems`, "get", params);
}

export const changeGroup = (params) => {
    return CallAPI(`${newUrl}changeGroup`, "post", params);
}

export const getConditionParams = (params) => {
    return CallAPI(`/api/cube/search/getConditionParams`, "get", params);
}
